<?php

namespace Product\Controller;
use Common\Controller\HomebaseController; 
/**
 * 文章
 */
class ArticleController extends HomebaseController {
    protected  $page_num = 10;
    /**
     * 文章详情页
     */
	public function detail1() {
        $id = I("get.id");
        $m_article = M("Article");
        $item = $m_article->where(array("id"=>$id))->find();
        $this->assign("item",$item);
		$this->assign("open_menu",false);
    	$this->display();
    }
    /**
     * 药品数据表
     */
    public function detail2(){
        $id = I("get.id");
        $m_article = M("Article");
        $item = $m_article->where(array("id"=>$id))->find();
        $this->assign("item",$item);
        $drug = M('data')->where(array('id'=>1))->find();
        $this->assign("drug",$drug);
        $this->display();
    }

    /**
     * 资讯频道
     */
    public function information(){
        $m_article = M("Article");
        $list = $m_article->where(array("tid"=>4))->order("sort")->select();
        $this->assign("list",$list);
        $this->assign("open_menu",false);
        $this->display();
    }

    /**
     * 夏季常用药
     */
    public function summer(){
        $page  = I('get.page');
        if(empty($page)){
            $page = 1;
        }
        $m_product = M("Products");
        $list = $m_product->where(array("is_hot"=>1))->order("sort")->limit(($page-1)*$this->page_num , $this->page_num)->select();
        $this->assign("list",$list);



        $count = $m_product->count();
        $this->assign("page",$page);
        $this->assign("count",$count);
        $this->assign("list",$list);
        $this->assign("page_num",ceil($count/$this->page_num));
        $this->assign("url",U('product/article/summer'));
        $this->display();
    }

    /**
     * 药品数据表
     */
    public function sheet(){
        $m_article = M("Article");
        $list = $m_article->where(array("tid"=>3))->order("sort")->select();

        if(sp_is_user_login()){
            $userid = sp_get_current_userid();
            $m_user = M('Users');
            $user = $m_user->where(array('id'=>$userid))->find();
            if($user['is_vip'] == 1){
                $this->assign("is_login",true);
            }

        }else{
            $this->assign("is_login",false);
        }

        $this->assign("list",$list);
        $this->display();
    }

}


